<template>
  <el-menu
    :default-active="activeIndex"
    :default-openeds="activeOpendsIndex"
    @open="handleOpen"
    @close="handleClose"
    background-color="#545c64"
    text-color="#fff"
    active-text-color="#ffd04b"
    :unique-opened=true>


    <el-menu-item index="7" @click="$router.push({name:'home'})">
      <i class="el-icon-s-home"></i>
      <span slot="title">首页</span>
    </el-menu-item>


    <el-submenu index="1">
      <template slot="title">
        <i class="el-icon-s-grid"></i>
        <span>机构管理</span>
      </template>
      <el-menu-item-group>
        <el-menu-item index="1-1" @click="$router.push({name:'org-subcom'})">
          分公司管理
        </el-menu-item>
        <el-menu-item index="1-2" @click="$router.push({name:'org-department'})">部门管理</el-menu-item>
        <el-menu-item index="1-3" @click="$router.push({name:'org-occupation'})">岗位管理</el-menu-item>
        <el-menu-item index="1-4" @click="$router.push({name:'org-staff'})">职工管理</el-menu-item>
        <el-menu-item index="1-5" @click="$router.push({name:'org-occupstaff'})">人岗管理</el-menu-item>
      </el-menu-item-group>
    </el-submenu>

    <el-submenu index="2">
      <template slot="title">
        <i class="el-icon-s-data"></i>
        <span>线路车辆管理</span>
      </template>
      <el-menu-item-group>
        <el-menu-item index="2-1" @click="$router.push({name:'line-station'})">站点管理</el-menu-item>
        <el-menu-item index="2-2" @click="$router.push({name:'line-line'})">线路管理</el-menu-item>
        <el-menu-item index="2-3" @click="$router.push({name:'line-milemark'})">里程标管理</el-menu-item>
        <el-menu-item index="2-4" @click="$router.push({name:'line-train'})">车辆管理</el-menu-item>
        <el-menu-item index="2-5" @click="$router.push({name:'line-component'})">具体组分管理</el-menu-item>
      </el-menu-item-group>
    </el-submenu>

    <el-menu-item index="3" @click="$router.push({name:'risk-risk'})">
      <i class="el-icon-message-solid"></i>
      <span slot="title">风险点管理</span>
    </el-menu-item>

    <el-submenu index="4">
      <template slot="title">
        <i class="el-icon-s-flag"></i>
        <span>事故管理</span>
      </template>
      <el-menu-item-group>
        <el-menu-item index="4-1" @click="$router.push({name:'accident-accType'})">事故类型管理 </el-menu-item>
        <el-menu-item index="4-2" @click="$router.push({name:'accident-accRecord'})">事故挖掘与分析</el-menu-item>
      </el-menu-item-group>
    </el-submenu>

    <el-submenu index="5">
      <template slot="title">
        <i class="el-icon-s-release"></i>
        <span>风险处置管理</span>
      </template>
      <el-menu-item-group>
        <el-menu-item index="5-1" @click="$router.push({name:'riskCope-copeRecord'})">处置跟踪填报</el-menu-item>
        <el-menu-item v-if="authorization.occupa_id === '003' || authorization.occupa_id === '001'" index="5-2" @click="$router.push({name:'riskCope-copeTest'})">处置跟踪考评</el-menu-item>
        <el-menu-item v-if="authorization.occupa_id === '003'" index="5-3" @click="$router.push({name:'riskCope-copeAna'})">处置结果分析</el-menu-item>
      </el-menu-item-group>
    </el-submenu>

    <el-menu-item index="6" @click="$router.push({name:'user-center'})">
      <i class="el-icon-setting"></i>
      <span slot="title">用户管理</span>
    </el-menu-item>

  </el-menu>
</template>

<script>
export default {
  name: "sideBar",
  props:{
    /*
    * 外部输入目前显示的页面内容
    * */
    pageIndex: {
      type: String
    },
    openIndex: {
      type: String
    }
  },
  data() {
    return{
      activeIndex: '1',
      activeOpendsIndex: ['0'],
      authorization:{
        occupa_id: ''
      }
    }
  },
  methods: {
    handleOpen(key, keyPath) {
    },
    handleClose(key, keyPath) {
    }
  },
  created() {
    this.activeIndex = this.pageIndex;
    if (this.openIndex != '0') {
      this.activeOpendsIndex.pop();
      this.activeOpendsIndex.push(this.openIndex);
    }
    this.$axios.get(`http://127.0.0.1:5000/getAuthorization`).then((res) => {
      console.log(res);
      this.authorization = res.data[0]
    });
   }

}
</script>
